<?php
/**
 * @file trynotice.php $
 * @author LiangJian (liangjian@haibao.com) $
 * @date 2015-4-21 下午7:54:34 $
 * @brief 试用中心公告数据层 $
 */
namespace haibao\cms\data;


class TryNotice extends \haibao\cms\data\BaseMysql{
	
	public function __construct(){
		parent::__construct('\haibao\cms\model\data\TryNotice');
	}
	
	public function getNoticeById($id){
		return $this->getOneById($id);
	}
	
	public function getNoticeByQuery($query){
		return $this->getAll($query);
	}
	
	public function addTryNotice($model){
		$this->add($model);
	}
	
	/**
	 * 更新公告内容
	 * @param \haibao\cms\model\data\TryNotice $model
	 */
	public function updateNoitceById($model){
		if(!$model->Id) return false;
		
		$this->updateById($model->Id, array(
			\haibao\cms\model\filter\TryNotice::CONDITION_FIELD_NAME_TITLE => $model->Title,
			\haibao\cms\model\filter\TryNotice::CONDITION_FIELD_NAME_URL => $model->Url,
			\haibao\cms\model\filter\TryNotice::CONDITION_FIELD_NAME_ISTOP => $model->IsTop,
			\haibao\cms\model\filter\TryNotice::CONDITION_FIELD_NAME_USER_ID => $model->UserId,
		));
	}
	
	/**
	 * 删除公告
	 */
	public function deleteNotice($id){
		if(!$id) return false;
		 
		$this->updateById($id, array(
			\haibao\cms\model\filter\TryNotice::CONDITION_FIELD_NAME_STATUS => \haibao\cms\model\data\TryNotice::STATUS_DISABLE
		));
	}
	
}